using System.Collections;
using System.Collections.Generic;
using cfg;
using cfg.enemy;
using cfg.skill;
using QFramework;
using UnityEngine;
using SimpleJSON;
public class LoadCofigManager : Singleton<LoadCofigManager>
{
    public Tables configTables { get; private set; }

    private LoadCofigManager()
    {
        LoadConfig();
    }

    public void LoadConfig()
    {
        //加载配置文件
        configTables = new cfg.Tables((file =>
        {
            var textAsset = Resources.Load<TextAsset>("Config/"+file);
            return JSON.Parse(textAsset.text);
        }));
    }

    #region 获取敌人配置信息
        public EnemyInfo GetEnemyInfo(int id)
        {
            return configTables.TbEnemy.Get(id);
        }
        public EnemyStateInfo GetEnemyStateInfo(int id)
        {
            return configTables.TbEnemyState.Get(id);
        }
    #endregion

    #region 获取技能的配置信息
    
        public SkillInfo GetSkillInfo(string id)
        {
            return configTables.TbSkillInfo.DataList.Find(x => x.Info.SkillId == id);
            //return configTables.TbSkillInfo.Get(id);
        }

        public SkillInfo GetSkillInfo(int id)
        {
            return configTables.TbSkillInfo.Get(id);
        }
        
        public  T GetSkillInfo<T>(string id) where T : cfg.Myskill.SkillInfoBase
        {
            return configTables.TbSkillInfo.DataList.Find(x => x.Info.SkillId == id).Info as T;
        }
    
    #endregion

}
